package com.zhuannimei.adapter;

import java.util.ArrayList;
import java.util.List;

import com.zhuannimei.R;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;

/*
 * pager页卡适配器
 */
public class BuyHistoryAdapter extends PagerAdapter {

	private List<View> views;
	private View view;
	private View view2;

	public BuyHistoryAdapter(Context context) {
		this.views = new ArrayList<View>();
		LayoutInflater mInflater = LayoutInflater.from(context);
		view = mInflater.inflate(R.layout.duihuan_history, null);
		view2 = mInflater.inflate(R.layout.onebuy_history, null);
		views.add(view);
		views.add(view2);
	}

	public View getFirstView() {
		return view;
	}

	public View getSecondView() {
		return view2;
	}

	@Override
	public int getCount() {
		return views.size();
	}

	@Override
	public boolean isViewFromObject(View arg0, Object arg1) {
		return arg0 == arg1;
	}

	@Override
	public void destroyItem(View container, int position, Object object) {
		((ViewPager) container).removeView(views.get(position));
	}

	@Override
	public Object instantiateItem(View container, int position) {
		((ViewPager) container).addView(views.get(position));
		return views.get(position);
	}

}
